package txt2bib;

import txt2bib.util.Util;
import java_cup.runtime.Symbol;

/**
 * 
 * @author v
 *
 */
public class GrammarError {
	private int column = 0;
	private int row = 0;
	private int symbolVal = -1;
	private String symbolString = "";
	private Symbol symbol = null;
	private String message = null;
	private Class<?> _class = null;
	/**
	 * 
	 */
	public GrammarError() {
		super();
	}
	
	
	public GrammarError(Symbol symbol, Class<?> _class) {
		this.row = symbol.left + 1;
		this.column = symbol.right + 1;
		this.symbolVal = symbol.sym;
		this.symbol = symbol;
		this.symbolString = symbol.value.toString();
		this._class = _class;
	}
	
	/**
	 * 
	 * @param row
	 * @param column
	 */
	public GrammarError(int row, int column) {
		this.row = row;
		this.column = column;
	}
	
	/**
	 * 
	 * @param row
	 * @param column
	 * @param symbol
	 */
	public GrammarError(int row, int column, int symbol) {
		this.row = row;
		this.column = column;
		this.symbolVal = symbol;
	}
	
	/**
	 * 
	 * @param row
	 * @param column
	 * @param message
	 */
	public GrammarError(int row, int column, String message) {
		this.row = row;
		this.column = column;
		this.message = message;
	}
	
	public int getColumn() {
		return column;
	}
	public void setColumn(int column) {
		this.column = column;
	}
	public int getRow() {
		return row;
	}
	public void setRow(int row) {
		this.row = row;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}

	public int getSymbolVal() {
		return symbolVal;
	}


	public void setSymbolVal(int symbolVal) {
		this.symbolVal = symbolVal;
	}


	public String getSymbolString() {
		return symbolString;
	}


	public void setSymbolString(String symbolString) {
		this.symbolString = symbolString;
	}


	public Symbol getSymbol() {
		return symbol;
	}


	public void setSymbol(Symbol symbol) {
		this.symbol = symbol;
	}


	@Override
	public String toString()  {
		StringBuffer m = new StringBuffer(/*"Errore"*/);
		//if (cur_token.left != -1) {
			m.append(" in linea " + row);
			m.append(", colonna " + column);
			
		//}
		m.append(", simbolo: " + symbolString + " " + Util.getSymbolHR(symbol, _class));
		//m.append(" : Errore di Sintassi\t");
		 
		return m.toString();
	}
	
}
